<?php /* EL PSY CONGROO */ /* EL PSY CONGROO */     	   			      		    	
#注册插件       	  	     							     	 		 	 	    			  			
RegisterPlugin("danblog","ActivePlugin_danblog");    	 	 			      			 			    	 	  	 	    		 		 	 
     				  	    	   				    		    		    		   			
function ActivePlugin_danblog() {      	          		   	  
	Add_Filter_Plugin('Filter_Plugin_Admin_TopMenu', 'danblog_AddMenu');  
	Add_Filter_Plugin('Filter_Plugin_ViewList_Template', 'danblog_Important');
	Add_Filter_Plugin('Filter_Plugin_ViewPost_Template', 'danblog_Important');
}    	 	 				         		 
    			 				    	  	    
//主题配置       		  	     		  	  
function danblog_AddMenu(&$m)      	   	     		      
{     		          						 
	global $zbp;    			          		  			
	array_unshift($m, MakeTopMenu("root",'主题配置',$zbp->host . "zb_users/theme/danblog/main.php?act=jbsz","","topmenu_danblog"));     	   	 	    	 	 			 
}      			       			 		  
        				    		   		 
//配置名称     			 		         				
function danblog_SubMenu($id){    		 			      		      
	$arySubMenu = array(   
	    0 => array('主题说明', 'config', 'left', false),
		1 => array('基本设置', 'jbsz', 'left', false),    		 	  		    					   
        2 => array('广告设置', 'guanggao', 'left', false), 
        3 => array('自定义CSS', 'zdycss', 'left', false), 
	);    	   	        		 	 		
	foreach($arySubMenu as $k => $v){    	   				      		 		 
		echo '<a href="?act='.$v[1].'" '.($v[3]==true?'target="_blank"':'').'><span class="m-'.$v[2].' '.($id==$v[1]?'m-now':'').'">'.$v[0].'</span></a>';       	   	     		 				
	}    	 	    	     	   	  
}      		        	 	 	 	 
function InstallPlugin_danblog(){    		  	 	     			 				
	global $zbp;    	 		           	   	
	if(!$zbp->Config('danblog')->HasKey('Version')){     	  	  	      		    
		$zbp->Config('danblog')->Version = '1.0';     		            					
		$zbp->Config('danblog')->Keywords = '网站关键词';      			 		     			  	 
        $zbp->Config('danblog')->Description = '网站描述';    		  			       		 	  
        $zbp->Config('danblog')->dibubanquan = '<p>Powered By <a href="http://zblogcn.com" target="_blank">Z-Blog</a> Theme By <a href="https://aizhancloud.com" target="_blank">爱站云</a> .</p>'; 
        $zbp->Config('danblog')->syad1kg = '0'; 
        $zbp->Config('danblog')->syad2kg = '0'; 
        $zbp->Config('danblog')->nyad1kg = '0'; 
        $zbp->Config('danblog')->nyad2kg = '0'; 
        $zbp->Config('danblog')->listimgkg = '1'; 
        $zbp->Config('danblog')->listtxtkg = '1'; 
        $zbp->Config('danblog')->zzjqkg = '1'; 
        $zbp->Config('danblog')->syjqkg = '0'; 
        $zbp->Config('danblog')->nyjqkg = '0'; 
        $zbp->Config('danblog')->ad1 = '网站后台->主题配置->广告设置->首页顶部广告';
        $zbp->Config('danblog')->ad2 = '网站后台->主题配置->广告设置->首页底部广告';
        $zbp->Config('danblog')->ad3 = '网站后台->主题配置->广告设置->文章顶部广告';
        $zbp->Config('danblog')->ad4 = '网站后台->主题配置->广告设置->文章底部广告';
		$zbp->SaveConfig('danblog');       	  		       		 		
	}       			 	    		  			 
  $zbp->SaveConfig('danblog');	     			 		     	 		 	  
}  
//友好时间 {TimeAgo($article.Time())}       		 	     		  		  
function danblog_TimeAgo( $ptime ) {       	 	       	 	    
    $ptime = strtotime($ptime);     	 		       		   			
    $etime = time() - $ptime;    	 		 	 	    			 				
    if($etime < 1) return '刚刚';     	    	     	  	  		
    $interval = array (     	 		 		    			   		
        12 * 30 * 24 * 60 * 60  =>  '年前 ('.date('Y-m-d', $ptime).')',      					      	 	 			
        30 * 24 * 60 * 60       =>  '个月前 ('.date('m-d', $ptime).')',    	 	    	    			 		  
        7 * 24 * 60 * 60        =>  '周前 ('.date('m-d', $ptime).')',     						      		   		
        24 * 60 * 60            =>  '天前',     	 		 		    	   		 	
        60 * 60                 =>  '小时前',     	  		 	    					 		
        60                      =>  '分钟前',     	  	 	      		 	 	 
        1                       =>  '秒前'       		 	     		 	  	 
    );     		 			         				
    foreach ($interval as $secs => $str) {     		    	    	  			  
        $d = $etime / $secs;    					 		     	 		   
        if ($d >= 1) {       					    	   	 	 
            $r = round($d);     		   		    				   	
            return $r . $str;    		 				      	  	  	
        }    	 	 			        	  		
    }
} 
//缩略图 {danblog_newsimg()}    		   			
function danblog_newsimg($article) {        	   
    global $zbp;    		      
    $matches = null;
    preg_match_all("/<img[^>]*src=\"([^\"]+\.(gif|jpeg|jpg|png))\"[^>]*>/i", $article->Content, $matches);
    if (count($matches[1]) > 0) {
        $img = $matches[1][0];
    return $img;  	  	    
    }    	 			 		
}  
function danblog_Important(){
	global $zbp;
	if(strpos($zbp->Config('danblog')->dibubanquan,'aizhancloud.com') == false){ 
	$zbp->footer .='<script type="text/javascript">alert("\u8bf7\u52ff\u4fee\u6539\u6216\u5220\u9664\u4e3b\u9898\u7248\u6743\u53ca\u4f5c\u8005\u4fe1\u606f\uff0c\n\u5426\u5219\u9875\u9762\u5c06\u65e0\u6cd5\u6b63\u5e38\u663e\u793a\uff0c\u8bf7\u91cd\u65b0\u5b89\u88c5\u4e3b\u9898\uff01");</script>'; }	
}
//卸载主题
function UninstallPlugin_danblog(){
	global $zbp;
}
?>